#ifndef MAINOBJECT_H
#define MAINOBJECT_H

#include <QSystemTrayIcon>
#include <QtGui/QApplication>
#include <QObject>
#include <QSettings>
#include <QDebug>
#include <QProcess>
#include <QFile>
#include <QMenu>
#include <QObject>
#include <QProcess>
#include "optionswin.h"
#include "filetrap.h"
#include "hotkeyeditor.h"
#include "textfieldwin.h"
#include "about.h"
#include "gs/globalshortcutmanager.h"
#include <QTemporaryFile>
#include <QDir>
#include <QUuid>
#include <QTranslator>
#include <QApplication>
#include <QMenuBar>
#include <QFileInfo>


#define EN_LOCATION "EN_LOCATION"
#define EN_LOCALE "EN_LOCALE"
#define EN_TEXT_NB "EN_TEXT_NB"
#define EN_FILE_NB "EN_FILE_NB"
#define EN_EXECUTABLE "\\ENScript.exe"
#define EN_TEXT_HOTKEY "EN_TEXT_HOTKEY"
#define EN_TEXT_HOTKEY_DEF ""
#define EN_TEXT_VISIBLE "EN_TEXT_VISIBLE"
#define EN_TEXT_POS "EN_TEXT_POS"
#define EN_TEXT_TAGS "EN_TEXT_TAGS"
#define EN_FILE_TAGS "EN_FILE_TAGS"
#define EN_FILE_SHIFT 150
#define EN_ACTIVE_OPACITY "EN_ACTIVE_OPACITY"
#define EN_INACTIVE_OPACITY "EN_INACTIVE_OPACITY"
#define EN_ACTIVE_OPACITY_DEF 100
#define EN_INACTIVE_OPACITY_DEF 50
#define EN_ONTOP "EN_ONTOP"
#define EN_ONTOP_DEF true
#define EN_PREMIUM "EN_PREMIUM"
#define EN_PREMIUM_DEF false
#define EN_POS_WIDTH "EN_POS_WIDTH"
#define EN_POS_HEIGHT "EN_POS_HEIGHT"
#define EN_POS_WIDTH_DEF 400
#define EN_POS_HEIGHT_DEF 56

#define EN_TEXT_VISIBLE_DEF false

#define EN_APP_NAME "ENTrap"
#define EN_ORG_NAME "Konstantin Vorobyev"
#define EN_PROGRAMFILES "PROGRAMFILES"
#define EN_DEFAULT_FOLDER "\\Evernote\\Evernote3"

class MainObject : public QObject{
    Q_OBJECT
public:
    OptionsWin* optionsWin;
    TextFieldWin* fieldWin;
    HotKeyEditor* hotkeyEditor;
    About *about;
    QSystemTrayIcon* trayIcon;
    QMenu *trayMenu;
    bool enFound;
    QString enLine;


    static MainObject* instance();
    void run(QApplication *app);
    void installTranslator();
    QStringList getNotebooks();
    bool createTextNote(QString aNote, QString aNotebook, QString aTitle, QString aType, QStringList tags);
    bool createFileNote(QString aFile, QString aNotebook, QString aType, QStringList tags);

public slots:
    void exitClicked();
    void optionsClicked();
    void aboutClicked();
    void connectHotkeys();
    void disconnectHotkeys();
    void toggleTextField(bool force = false);
    void trayActivated(QSystemTrayIcon::ActivationReason reason);
private:
    static MainObject* instance_;

    QString maskAllShit(QString aString);
    bool callEN(QString operation, QStringList params, QString input, QString *output);
    bool callENMac(QStringList input, QString *output);
};

#endif // MAINOBJECT_H
